// TOWN DIALOGUE SCRIPT
//    Town 47: Erika's Tower

begintalkscript;

variables;

short i,j,k,r1,choice;

begintalknode;
	tag = 10;
	state = -1;
	nextstate = -1;
	condition = 1;
	text1 = "The golem stares straight ahead, waiting for Erika to tell it to smash something.";


// Erika

begintalknode;
	tag = 40;
	state = -1;
	nextstate = 1;
	question = "Erika";
	text1 = "You stand before Erika, master archmage of Avernum. She looks surprisingly young. Only the cold, tired look in her eyes reveals her true age. Her skin is porcelain pale.";
	text2 = "_Welcome, surface explorer. I am called Erika. Simply Erika. I heard of your successes, and I allowed you to come to me._ She seems to be pondering how you can best serve her interests.";
	text5 = "Erika sits in her throne and watches you coldly, as if you were a particularly intriguing new form of insect. Her self-inflicted exile in this tower must be very boring. There are books piled everywhere.";
	action = INTRO;

begintalknode;
	state = 1;
	nextstate = 1;
	condition = gf(47,13) == 0;
	question = "_Greetings to you, Erika the archmage._";
	text1 = "_Greetings. Welcome to my tower. Or, at least, this room of it. You may explore my halls if you wish, but bear in mind that your safety may be at risk._";
	text2 = "_I have allowed you to pierce my defenses because it has become clear that I should involve myself in the events above. Come closer. There is much we should discuss. I want to tell you my story and give you a boon._";
	action = SET_SDF 47 13 1;

begintalknode;
	state = 1;
	nextstate = -1;
	condition = gf(47,13) >= 1;
	question = "_Why have you adopted such a simple title?_";
	text1 = "_The only use of fancy titles is to draw attention away from one's lack of power._";

begintalknode;
	state = 1;
	nextstate = 2;
	condition = gf(47,13) >= 1;
	question = "_What exactly are you doing out here in this tower?_";
	text1 = "_I have many jobs. I am the greatest wizard in Avernum. I am an absolute foe of the Empire. I have an assortment of hobbies. I teach magic, sometimes. Which of these interests you?_";

begintalknode;
	state = 2;
	nextstate = 3;
	question = "_But there are so many mages. How can you say you're the best?_";
	text1 = "She shrugs. _It is a simple truth. There are mages in Avernum whose work I admire, but none of them are any match for me, and none have assisted Avernum as I have._";

begintalknode;
	state = 3;
	nextstate = 1;
	question = "_How have you assisted Avernum?_";
	text1 = "_I would be happy to tell you my story._";

begintalknode;
	state = 2;
	nextstate = 15;
	question = "_Why do you hate the Empire so much?_";
	text1 = "_The Empire cast me into Avernum. I will destroy it, whatever I do! I believe you are sympathetic to this._";

begintalknode;
	state = 15;
	nextstate = 2;
	question = "_So do you plan to destroy the Empire with plagues of monsters?_";
	text1 = "_I wish for the destruction of the Empire, but that doesn't mean I am responsible for the monsters up there. I have no desire to make the surface uninhabitable for humans. Despite what you may think, I do care about Avernum and its people._";


begintalknode;
	state = 2;
	nextstate = 20;
	question = "_What are your hobbies?_";
	text1 = "_You would not comprehend them. Best you do not ask. And, if you do not want any of my hobbies to harm you, do not stray too far from this hall._";
	
begintalknode;
	state = 20;
	nextstate = -1;
	condition = gf(24,16) == 1;
	question = "_That reminds me, Mahdavi asked me to read your notes on the vahnatai._";
	text1 = "_Oh, did she? Well, I can't let you see all of my research. She'll have to do it on her own. But I think I left some of my lesser observations around somewhere. Look around if you want. But don't be surprised if one of my experiments kills you._";


begintalknode;
	state = 1;
	nextstate = 5;
	condition = gf(47,13) >= 1;
	question = "_Please tell me your story._";
	text1 = "She is calm as her story begins, but the more she speaks. the angrier she gets. It's a fearsome sight. _I was a mage on the surface, working for the Empire. There was a power struggle. We all fought for Emperor Hawthorne's favor._";
	text2 = "_My side lost. I, Patrick, Solberg and others were cast down into the depths, and I, their leader, was cursed!_";

begintalknode;
	state = 5;
	nextstate = -1;
	question = "_What do you think of your fellow mages, such as Patrick?_";
	text1 = "_Competent, lesser mages._ She shakes her head. _Of course, Patrick is dead now. He was a solid man, competent in his way. I mourned him._";

begintalknode;
	state = 5;
	nextstate = -1;
	question = "_How were you cursed?_";
	text1 = "She digs her nails into the arm of her chair. _They dared to lay spells on me! If ever the light of the sun touches me again, I will die in an instant! I have no hope of ever leaving these caves! For that, the surface filth must pay!_";

begintalknode;
	state = 5;
	nextstate = 6;
	question = "_What was Avernum like when you first went down there?_";
	text1 = "_We found Avernum to be a string of filthy caves, filled with scum-encrusted, beleaguered humans fighting desperately for survival. There were nephilim, the savage slithzerikai, and a horde of demons. A terrible mess._";
	text2 = "_One of the warriors, named Micah, was trying to bring order, but not having much luck. With the aid of my power, everything changed._";

begintalknode;
	state = 6;
	nextstate = -1;
	question = "_Whatever happened to Micah?_";
	text1 = "_He's the king now, and has been for over twenty years. He has a few good years ahead of him._";

begintalknode;
	state = 6;
	nextstate = 7;
	question = "_How did your power change Avernum?_";
	text1 = "_We brought magic to the pit. I found a way to fetch my magical tomes from the surface, and, using our combined powers, we tamed the squabbling bands, formed cities, formed schools, beat back the dark forces, and formed a nation._";
	text2 = "_That left only the surface filth to deal with._";

begintalknode;
	state = 7;
	nextstate = -1;
	question = "_What dark forces did you have to fight off?_";
	text1 = "_The demon lord Grah-Hoth lived in the caves. We defeated and imprisoned him, but it was a close thing._";

begintalknode;
	state = 7;
	nextstate = 8;
	question = "_The surface filth? You mean the Empire?_";
	text1 = "_I said the Empire must pay for what they did to me, and they did! I sent a band of assassins up to kill Emperor Hawthorne! I'm glad I did it! Then they invaded us, and we killed many more of them!_";
	text2 = "_Even after all of that, that is still only the beginning of my vengeance!_";

begintalknode;
	state = 8;
	nextstate = 9;
	question = "_So are these monster plagues part of your vengeance on the Empire?_";
	text1 = "She shakes her head. _I wish great vengeance on the Empire, but the plagues of monsters are not my doing. Despite what people say, I am not insane._";

begintalknode;
	state = 9;
	nextstate = 10;
	question = "_What proof do you have that you're not responsible?_";
	text1 = "_I long to see the sun again, but I cannot. That does not mean I wish to deny that pleasure to those I watch over. I am not responsible for the carnage up there, no matter what evidence you find._";

begintalknode;
	state = 10;
	nextstate = -1;
	question = "_Aren't you glad about what is happening up there?_";
	text1 = "_No. No, I am not. The devastation up there is not hurting the Empire as much as it's hurting its people. It's simple carnage, not proper vengeance. And it denies the Avernites a chance to return to the sun._";
	text2 = "_No, I do not approve at all._";

begintalknode;
	state = 10;
	nextstate = -1;
	question = "_What if we were to find evidence implicating you?_";
	text1 = "_You can't have any evidence that I was responsible. Don't waste my time!_";
	text3 = "_Yes, I heard of the symbol you found in the slime pit,_ she scoffs. _I am many things, but I am not a fool! You think I would leave my symbol there for anyone to find, large as life, to lead them back to me? If you believe that, you're a fool._ ";
	action = DEP_ON_SDF 309 0 0;

begintalknode;
	state = 20;
	nextstate = 21;
	question = "_Why shouldn't I stray past the halls?_";
	text1 = "_I have experiments active in my halls, as well as traps to ensnare spies. I would so hate to have to throw your remains into my trash pits._";

begintalknode;
	state = 21;
	nextstate = 22;
	question = "_Where are these trash pits?_";
	text1 = "_Don't enter my tower from the back. That's where I put my experiments that, well, don't work out._ She thinks. _Hmm. That may be where I left that wand._";

begintalknode;
	state = 22;
	nextstate = 2;
	question = "_What wand?_";
	text1 = "She looks annoyed. _I was merely thinking aloud._";

begintalknode;
	state = 1;
	nextstate = 17;
	condition = gf(47,13) >= 1;
	question = "_I would like to learn more about magic._";
	text1 = "_I have taught those of Avernum for many years, and sometimes still do so. You may purchase spells if you wish. Beware, though. My time does not come cheaply._";
	text2 = "_Also, if you are able to tithe me properly for my time, I may be able to help you improve the efficiency of your spells._";

begintalknode;
	state = 17;
	nextstate = -1;
	question = "_Can you teach me some of your spells?_";
	text1 = "You conclude your business.";
	code =
		begin_shop_mode("Erika's Spells","Learning magic directly from Erika herself is a rare honor. She knows rituals which are almost impossible to find anywhere else.",13,5,3);
	break;

begintalknode;
	state = 17;
	nextstate = -1;
	condition = get_prestige() < 30;
	question = "_Can you help me improve our magical skills?_";
	text1 = "She thinks it over. _This is a very rare privilege, and not an honor I bestow lightly. Do a bit more adventuring, and maybe I will decide to spend the time on you._";

begintalknode;
	state = 17;
	nextstate = -1;
	condition = get_prestige() >= 30;
	question = "_Can you help me improve my magical skills?_";
	text1 = "You conclude your business.";
	code =
		begin_shop_mode("Erika's Training","Erika knows many powerful and secret tricks for improving the efficiency of your spells. She is a harsh and unpleasant teacher, but she knows a lot.",14,6,3);
	break;

begintalknode;
	state = 17;
	nextstate = 1;
	question = "_I don't need any instruction right now._";
	text1 = "_It's your decision._";
	
begintalknode;
	state = 1;
	nextstate = 16;
	condition = gf(47,13) >= 1;
	question = "_What boon did you wish to give me?_";
	text1 = "_There is an amulet I wish to give you. It will enable me to keep track of your movements and, if necessary, aid you._";
	text3 = "_You've received my boon. What you do with it is your choice._";
	action = DEP_ON_SDF 47 8 2;

begintalknode;
	state = 16;
	nextstate = 2;
	condition = gf(47,8) <= 1;
	question = "_Can you tell me more about this amulet?_";
	code =
		run_hardcode(123);
	break;

begintalknode;
	state = 1;
	nextstate = 30;
	condition = gf(47,8) == 2;
	question = "_I got that amulet you mentioned._";
	text1 = "You present the amulet to Erika. She says _Excellent. Now I wish to cast a spell, bonding the amulet to you. If you accept, I will be able to track your progress, and, if things get truly desperate, I can aid you._";
	text2 = "_Be warned, however. I have little patience with those who spurn my aid. This is the only time this boon will be offered. Do you accept it?_";

begintalknode;
	state = 30;
	nextstate = 1;
	condition = 1;
	question = "_I accept your aid._";
	code =
		sf(47,28,1);
		run_hardcode(123);
	break;

begintalknode;
	state = 30;
	nextstate = 1;
	condition = 1;
	question = "_I refuse your aid._";
	code =
		sf(47,28,2);
		run_hardcode(123);
	break;

begintalknode;
	state = 1;
	nextstate = -1;
	condition = gf(47,8) == 3 && gf(47,12) == 1;
	question = "_I changed my mind. Can you still give that boon amulet?_";
	code =
		run_hardcode(123);
	break;

begintalknode;
	state = 1;
	nextstate = 35;
	condition = gf(47,13) >= 1 && ((gf(309,0) >= 1) || (gf(309,1) >= 1) || (gf(309,8) >= 1));
	question = "_I have learned more about the source of the monster plagues._";
	text1 = "_I'm glad you have come to me. Tell me what you know._";


begintalknode;
	state = 35;
	nextstate = -1;
	condition = gf(47,13) >= 1 && gf(309,0) >= 1;
	question = "_I found your symbol in the slime pit, the source, on the surface, of a plague of monsters._";
	text1 = "_Yes, I know. That is one of the reasons that I have welcomed you here. Before you judge me too harshly based on that ludicrously obvious attempt to cast doubt upon me, there is a story I want to tell you._";
	text3 = "_Yes, I know. The vahnatai were cunning. They knew that my history would make me a likely candidate for blame. Any who knew my story would think that I might seek revenge in this manner._";
	action = DEP_ON_SDF 308 7 0;

begintalknode;
	state = 35;
	nextstate = -1;
	condition = gf(309,1) >= 1;
	question = "_I have found evidence that the dragons are responsible for the monster plagues._";
	text1 = "_It would not surprise me if they have a hand in this. They are powerful, they are on the surface, and they hate the Empire. I shall see if I can contact them and learn more of this matter._";
	text3 = "_Perhaps. But they are not responsible. The vahnatai are._";
	action = DEP_ON_SDF 308 7 0;

begintalknode;
	state = 35;
	nextstate = -1;
	condition = gf(309,8) >= 1;
	question = "_I found evidence that the vahnatai are responsible for the plagues of monsters._";
	text1 = "_I would not be surprised. They hate the Empire, and they have the power. You should search the surface further. Perhaps you will find the true identity of our hidden foe._";
	text3 = "_And so they were. Now that we know who the true enemy is, I have been hard at work trying to find ways to deal with them._";
	action = DEP_ON_SDF 308 7 0;

begintalknode;
	state = 1;
	nextstate = -1;
	condition = gf(47,13) >= 1;
	question = "_That is all I need._";
	text1 = "_Then I wish you luck. I truly do. You can return to the surface. For all my power, I must still envy you._";
	action = END_TALK;
